package com.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import java.util.ArrayList;
import java.util.List;

@Controller
@RequestMapping("xixi")
public class formController {
    @RequestMapping("addUser")
    public ModelAndView addUser(@RequestParam("name") String username, @RequestParam String password, Integer verificationCode) {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("username", "传入的名字是：" + username);
        modelAndView.addObject("password", "传入的密码是：" + password);
        modelAndView.addObject("verificationCode", "传入的验证码是：" + verificationCode);
        modelAndView.setViewName("stringview");
        return modelAndView;
    }
    @RequestMapping("deleteUser")
    public ModelAndView deleteUsers(int[] ids){
        ModelAndView modelAndView = new ModelAndView();
        List<Integer> list = new ArrayList<>();
        for (int id : ids) {
            list.add(id);
        }
        modelAndView.addObject("ids", "传入的数组是："+list);
        modelAndView.setViewName("arrayview");
        return modelAndView;
    }
}